package com.wwt.server.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wwt.server.mapper.AdminRoleMapper;
import com.wwt.server.pojo.AdminRole;
import com.wwt.server.service.IAdminRoleService;
import com.wwt.server.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Tao
 * @since 2021-12-05
 */
@Service
@Transactional
public class AdminRoleServiceImpl extends ServiceImpl<AdminRoleMapper, AdminRole> implements IAdminRoleService {

    @Autowired
    private AdminRoleMapper adminRoleMapper;
    @Override
    public Result updateByAdminId(Integer adminId, Integer[] rids) {
        QueryWrapper<AdminRole> wrapper = new QueryWrapper<>();
        wrapper.eq("adminId",adminId);
        int i = adminRoleMapper.delete(wrapper);
        int result = adminRoleMapper.updateByAdminId(adminId, rids);
        if (result == rids.length && i>0){
           return Result.success("更新成功！");
        }
        return Result.fail("更新失败！");
    }
}
